package com.sample.transitiondemo;

import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.PorterDuff;
import android.graphics.PorterDuffXfermode;
import android.util.AttributeSet;
import android.widget.ImageView;

/**
 * Created by guo
 *
 * @ 2016/11/4
 */

public class ConnerImageView extends ImageView {
    public ConnerImageView(Context context) {
        super(context);
    }

    public ConnerImageView(Context context, AttributeSet attrs) {
        super(context, attrs);
    }

    public ConnerImageView(Context context, AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
    }


    @Override
    protected void onDraw(Canvas canvas) {
        super.onDraw(canvas);
        Paint p1 = new Paint();
        canvas.drawColor(Color.WHITE);

       /*
        //平移
        p1.setColor(Color.BLUE);
        canvas.drawCircle(100, 100, 50, p1);
        p1.setColor(Color.GREEN);
        canvas.drawCircle(200, 200, 50, p1);
        canvas.save();

        canvas.translate(100, 100);
        p1.setColor(Color.RED);
        canvas.drawCircle(200, 200, 50, p1);
        canvas.restore();*/


        p1.setColor(Color.RED);
        p1.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.DST_IN));
        canvas.drawCircle(100, 100, 200, p1);

        p1.setColor(Color.BLUE);
        canvas.drawCircle(150, 150, 200, p1);
    }
}
